﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class SelectDiag : Form
    {
        private Diagnose selectedDiag;
        private List<Diagnose> diagList;

        public SelectDiag(List<Diagnose> diagList)
        {
            this.diagList = diagList;
            InitializeComponent();
            foreach (var el in diagList)
            {
                DiagNameListBox.Items.Add(el.name.ToString());
            }
        }

        public Diagnose GetSelectedItem()
        {
            return selectedDiag;
        }

        private void DiagDescTextBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            Diagnose d = diagList[DiagNameListBox.SelectedIndex];
            DiagDescTextBox.Text = d.description;
            selectedDiag = d;
        }

        private void OKBtn_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        private void CancelBtn_Click(object sender, EventArgs e)
        {
            Close();
        }

    }
}
